<template>
  <view class="scrollbox">
    <u-navbar title="企业人员">
      <template #right>
        <!--  -->
        <view class="edtbtn" @click="onedt"> 添加 </view>
      </template>
    </u-navbar>
    <getdatascrollview ref="getdatascrollview" :api="api" :seardata="tablequery">
      <template #default="{ list }">
        <view class="searchcontent">
          <deptSelect v-model="searchdata.deptId" style="flex: 1;" @change="change"></deptSelect>
          <view class="sx" @click="sxfn">
            筛选<u-icon name="arrow-down"></u-icon>
          </view>
        </view>
        <listcard v-for="item in list" :item="item" :list="listinputs" @click="ontap">
          <template #before>
            <view>
              {{ item.deptName }}
            </view>
            <view>
              {{ item.name }}
            </view>
          </template>
        </listcard>
      </template>
    </getdatascrollview>
    <sxpopup ref="sxpopup" :searchdata="searchdata"></sxpopup>
  </view>
</template>

<script>
import { pageList } from "@/api/company/empInfo";
export default {
  components: {},
  data() {
    return {
      customstyle: {
        margin: 0,
        flex: 0,
      },
      tablequery: {},
      api: pageList,
      searchdata: {},
      searchinputs: [
        {
          label: "人员姓名",
          value: "name",
        },
        {
          label: "身份证号",
          value: "cardNum",
        },
        {
          label: "毕业院校",
          value: "school",
        },
        {
          label: "职工状态",
          value: "status",
          type: "select",
          option:
            this.$store.state.dict.dictDatas[
            this.$store.state.dict.DICT_TYPE.EMPLOYEE_STATUS
            ],
        },
      ],
      listinputs: [
        {
          label: "岗位",
          value: "job",
          type: "select",
          option:
            this.$store.state.dict.dictDatas[
            this.$store.state.dict.DICT_TYPE.JOB_POST
            ],
        },
        {
          label: "性别",
          value: "sex",
          type: "select",
          option:
            this.$store.state.dict.dictDatas[
            this.$store.state.dict.DICT_TYPE.SYSTEM_USER_SEX
            ],
        },
        {
          label: "身份证",
          value: "cardNum",
        },
        {
          label: "手机号",
          value: "telNum",
        },
        {
          label: "最高学历毕业院校",
          value: "school",
        },
        {
          label: "职工状态",
          value: "status",
          type: "select",
          option:
            this.$store.state.dict.dictDatas[
            this.$store.state.dict.DICT_TYPE.EMPLOYEE_STATUS
            ],
        },
        {
          label: "入职时间",
          value: "entryTime",
          type: "date",
        },
        {
          label: "离职时间",
          value: "dimissionTime",
          type: "date",
        },
      ],
    };
  },
  mouted() { },
  onShow() {
    this.$refs.getdatascrollview && this.$refs.getdatascrollview.onRefresh();
  },
  methods: {
    change() {
      // console.log(this.searchdata.deptId, "this.tablequery");
      this.onsearch();
    },
    sxfn() {
      this.$refs.sxpopup.open(this.searchinputs).then((data) => {
        this.searchdata = {
          ...this.searchdata,
          ...data,
        };
        this.onsearch();
      });
    },
    async onsearch() {
      this.tablequery = {
        ...this.searchdata,
      };

      this.$nextTick(() => {
        this.$refs.getdatascrollview.onRefresh();
      });
    },
    ondel(row) {
      console.log(row);
      uni.showModal({
        title: "提示",
        content: "是否删除此数据？",
        success: (res) => {
          if (res.confirm) {
            deleteCompanyFile([row.uuid]).then((e) => {
              this.onsearch();
            });
          } else if (res.cancel) {
            console.log("用户点击取消");
          }
        },
      });
    },
    onedt() {
      uni.navigateTo({
        url: "/pageswork/company/empInfo/edit",
      });
    },
    ontap(item) {
      uni.navigateTo({
        url: `/pageswork/company/empInfo/edit?id=${item.id}`,
      });
      //   console.log(item);
    },
  },
};
</script>
<style>
page {
  background: #fff;
}
</style>
<style lang="scss" scoped>
.edtbtn {
  color: #1890ff;
  font-size: 28rpx;
}

.searchcontent {
  display: flex;
  align-items: center;
  padding: 20rpx 20rpx 0 20rpx;

  .sx {
    padding-left: 20rpx;
    display: flex;
    font-size: 28rpx;
  }
}
</style>
